package Q977

import java.util.*

class Main {
}

class Solution {
    fun sortedSquares(nums: IntArray): IntArray {
//        Arrays.sort(nums)
        for(i in nums.indices){
            nums[i] = Math.pow(nums[i].toDouble(),2.0).toInt()
        }
        Arrays.sort(nums)
        return nums
    }
}

fun main(){
    var num = intArrayOf(-4,-1,0,3,10)
    var sortedSquares = Solution().sortedSquares(num)
    for(i in sortedSquares){
        println(i)
    }
}